package com.iknow.xmpp.smack.avatar;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class HttpAvatarRetriever
  implements AvatarRetriever
{
  private URL mUrl;
  private String mUrlString;

  public HttpAvatarRetriever(String paramString)
  {
    this.mUrlString = paramString;
  }

  public HttpAvatarRetriever(URL paramURL)
  {
    this.mUrl = paramURL;
  }

  public byte[] getAvatar()
    throws IOException
  {
    byte[] arrayOfByte;
    int i;
    if (this.mUrl == null)
      this.mUrl = new URL(this.mUrlString);
    InputStream localInputStream = this.mUrl.openStream();
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    try
    {
      arrayOfByte = new byte[1024];
      i = localInputStream.read(arrayOfByte);
      if (i == -1)
      {
        localInputStream.close();
        localByteArrayOutputStream.close();
      }
    }
    finally
    {
      localInputStream.close();
      localByteArrayOutputStream.close();
    }
  }
}